package com.paomi.client.activity.person.presenter;

import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.hannesdorfmann.mosby3.mvp.MvpView;
import com.paomi.client.activity.person.View.CollectionView;
import com.paomi.client.bean.BaseJSON;
import com.paomi.client.bean.CollectionListInfo;
import com.paomi.client.net.Api;
import com.paomi.client.net.BaseCallback;
import com.paomi.client.net.Constants;
import com.paomi.client.view.LoadingDialog;

import java.util.Map;

import retrofit2.Call;

public class CollectionPre extends MvpBasePresenter<CollectionView> {

    /**
     * 获取收藏列表
     *
     * @param type 收藏类型 0 演出项目 1 衍生品 2 资讯
     */
    public void getFavorList(String type,int pageNum) {
        LoadingDialog.get().showLoading();
        Api.getInstanceService(Constants.Ticket_URL).getAddFavor(type,""+pageNum,""+Constants.PAGE_SIZE).enqueue(new BaseCallback<CollectionListInfo>() {
            @Override
            public void onResponse(Call<CollectionListInfo> call, CollectionListInfo result) {
                if(isViewAttached())
                getView().showCollection(result);
            }
        });
    }

    /**
     * 取消收藏
     */
    public void removeCollection(Map map,int pos) {
        Api.getInstanceService(Constants.Ticket_URL).getaddCollection(map).enqueue(new BaseCallback<BaseJSON>() {
            @Override
            public void onResponse(Call<BaseJSON> call, BaseJSON result) {
                getView().removeSuccess(result,pos);
            }
        });
    }
}
